var connector = require("../../../src/runtime/jaba");

var index = 0;

console.log("All but first 2 orders in WA:");

(function($service$){
var $input$ = {};

/* Init code */

/* Remote code */
var $script$ = 'for customer in root.Customers do (if ((customer.Region == "WA")) then (for order in customer.Orders do (g0:order.Customer.CustomerID; g1:order.OrderID; g2:order.OrderDate) end; ) end; ) end; ';
var $batch$ = $service$.execute($script$, $input$, function($result$) {

/* Local code */
$result$.getIteration("customer").forEach(function(customer){
customer.getIteration("order").forEach(function(order){
if( (index > 1) )
console.log(((((("CustomerID=" + order.getString("g0")) + " OrderID=") + order.getString("g1")) + " OrderDate=") + order.getString("g2")));
 else index++ ;
});
});

});
})(connector);